package easy;

public class Solution_941 {

    public boolean validMountainArray(int[] arr) {
        if (arr.length < 3) {
            return false;
        }
        boolean flag_1 = false, flag_2 = false;
        int i = 0, j = arr.length - 1;
        for (; i < j && !(flag_1 && flag_2); ) {
            if (arr[i] < arr[i + 1]) {
                i++;
            } else {
                flag_1 = true;
            }
            if (arr[j] < arr[j - 1]) {
                j--;
            } else {
                flag_2 = true;
            }
        }
        return i != 0 && j != arr.length - 1 && i == j;
    }

    public static void main(String[] args) {
        Solution_941 model = new Solution_941();
        System.out.println(model.validMountainArray(new int[]{2, 1}));
        System.out.println(model.validMountainArray(new int[]{3, 5, 5}));
        System.out.println(model.validMountainArray(new int[]{3, 5, 2}));
        System.out.println(model.validMountainArray(new int[]{3, 5, 2}));
    }
}
